I encountered this problem as well.
It does not affect iOS 16, but does affect iOS 17 and 18. It's reproducible in the simulator as well as on device.
In my case I was able to use DataRepresentation with a suggestedFileName instead.
In this example, it would look like this:
struct TextFile: Transferable {
let content: String
let filename: String
static var transferRepresentation: some TransferRepresentation {
DataRepresentation(exportedContentType: .data) {
textFile in
return textFile.content.data(using: .utf8) ?? Data()
}
.suggestedFileName {
textFile in
return textFile.filename
}
}
}
Caveats:
Requires iOS 17+ if you want to use this suggestedFileName method.
Isn't feasible for large files that won't fit in memory.